<?php
/**
 * dbfront
 * (c) 2010-2013 Stephen Adkins <spadkins@gmail.com>
 * This software began development in 2010.
 * It is based on code dating from 1999.
 *
 * License: GPL 2.0
 * The contents of this file may be used under the terms of
 * the GNU General Public License Version 2 or later (the "GPL").
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 * */
namespace App;
class Service {
    public $type, $name, $class;
    protected $context, $conf;
    public function getConf() {
        return($this->conf);
    }
    public function __construct($context, $type, $name, $conf) {
        global $trace;
        if ($trace) trace_entry();
        $this->context = $context;
        $this->class   = get_class($this);
        $this->type    = $type;
        $this->name    = $name;
        if (!isset($conf)) $conf = array();
        $this->conf    = $conf;
        if ($trace) trace_exit();
    }
    public function __toString() {
        $object_class = str_replace('App\\','',get_class($this));
        $str = "$object_class($this->name)";
        $first = 1;
        foreach ($this as $key => $value) {
            if (is_scalar($value) && !preg_match('/pass/',$key) && isset($value) && $value != '') {
                $str .= $first ? '=[' : ',';
                $str .= "$key=$value";
                $first = 0;
            }
        }
        if (!$first) $str .= ']';
        return($str);
    }
}
